#include <QtGui>
#include "data.h"

class ColorPath
{

public:
  ColorPath(QPainterPath* pp, QColor c);
  QColor getColor();
  QPainterPath* getPP(); 

private:
  QPainterPath *path;
  QColor color;
};


class GraphWid : public QWidget
{
  
 Q_OBJECT
    
 public:
  GraphWid(QWidget *parent);
  void setData(DataHRM *data);
  void print(QPrinter *printer);

 public slots:
  void scrolling(bool);
  void caretMoving(int);
  void setHRVisible(bool);
  void setAltVisible(bool);
  void setSpeedVisible(bool);
  
 protected:
  void paintEvent(QPaintEvent *e);
  void mouseMoveEvent(QMouseEvent *e);
  void mousePressEvent(QMouseEvent *e);
  void leaveEvent(QEvent *);
  void resizeEvent(QResizeEvent *event);
  
 signals:
  void hrChanged(int newValue);
  void speedChanged(double newValue);
  void altChanged(int newValue);
  void cronoChanged(int newValue);

 private:
  QVector<ColorPath*>* createColorPath(QVector<int>* vect, qreal min, qreal mid, 
	qreal max, QColor midColor, QColor maxColor);
  void drawPathColor(QPainter* painter, QVector<ColorPath*>* line, Qt::PenStyle style);

  QPrinter printer;
  QVector<int> *vectHR;
  QVector<ColorPath*> *lineHR;
  QVector<int> *vectSpeed;
  QVector<ColorPath*> *lineSpeed;
  QVector<int> *vectAlt;
  QVector<ColorPath*> *lineAlt;
  qreal scaleH;
  qreal maxHR;
  qreal maxSpeed;
  qreal maxAlt;
  int xtooltip;
  int ytooltip;
  int caretX;
  int caretY;
  bool autoScroll;
  bool isScrolling;
  bool hrVis;
  bool altVis;
  bool speedVis;


};
